/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modele;

import java.util.Collection;
import java.util.HashSet;

/**
 *
 * @author mbamba
 */
public class Pays {
    
    private Collection<Dep>lesDeps=new HashSet<Dep>();
    private Collection<Spe>lesSpes=new HashSet<Spe>();
    
    public Pays(){
        lesDeps=DAO.getLesDeps();
        lesSpes=DAO.getLesSpes();
        this.assocMedecins(DAO.getLesMeds());
    }

    public Collection<Dep> getLesDeps() {
        return lesDeps;
    }
    
    public Collection<Spe> getLesSpes() {
        return lesSpes;
    }
    
    private void assocMedecins(Collection<Med> lesMeds){
        for (Med unMed : lesMeds){
            getLeDep(unMed.getDep()).addUnMed(unMed);
            Spe uneSpe = getLaSpe(unMed.getSpe());
            if(uneSpe != null){
                uneSpe.addUnMed(unMed);
            }
        }
    }
    
    public Dep getLeDep(String numDep){
        for(Dep d:lesDeps){
            if(d.getNum().equals(numDep)){
                return d;
            }
        }
        return null;
    }
    
    public Spe getLaSpe(String nomSpe){
        for(Spe s:lesSpes){
            if(s.getSpe().equals(nomSpe)){
                return s;
            }
        }
        return null;
    }
    
    
}
